<%@ include file="/WEB-INF/template/include.jsp"%>
<%@ include file="localHeader.jsp"%>
<openmrs:htmlInclude file="/scripts/calendar/calendar.js" />
<openmrs:require privilege="View Orders" otherwise="/login.htm" redirect="/module/simplelabentry/labOrderResultForm.htm" />

<form action="resultEntry.htm" method="get">
    <div id="cohort_builder_add_filter" style="padding: 4px; width: 68%; float: left;">
        <div id="cohortSearchTabs">
            <ul>
                <li>&nbsp;</li>

                <c:forEach items="${headingList}" var="tabHeading">
                    <c:choose>
                        <li><a id="searchTab_${tabHeading.name}" href="#" onClick="changeSearchTab(this)"><spring:message code="${tabHeading.name}"/></a></li>
                        <input type="hidden" id="default" name="default" value="searchTab_${tabHeading.name}"/>
                    </c:choose>
                </c:forEach>
            </ul>
            <b class="boxHeader">Select Test</b>
            <div class="box">
                <div id="cohortSearchTabContent" style="border: 1px black solid; border-top: none; padding: 4px 5px 2px 10px;">
                    <c:forEach items="${headingList}" var="tabHeading">
                        <div id="searchTab_${tabHeading.name}_content" style="display: none">
                            <table style="width: 100%;">
                                <tbody>
                                    <tr style="background-color: rgb(204, 204, 204);">
                                        <th></th>
                                        <th>Location</th>
                                        <th>Date</th>
                                        <th>Tests</th>
                                        <th></th>
                                    </tr>
                                    <tr>
                                        <td><input type="text" name="orderDate" size="10" value="" onFocus="showCalendar(this)"/></td>
                                        <td><openmrs_tag:locationField formFieldName="orderLocation" initialValue=""/></td>
                                    <td>
                                    <c:forEach items="${tabHeading.answers}" var="answers">
                                        <input type="Submit" name="test" value="${answers.answerConcept.name}" onSubmit="this.form.submit()"/><br/>

                                    </c:forEach>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </c:forEach>
                    <form action="labOrderResultForm.htm" method="get">
                        <simplelabentry:groupedOrderTag name="groupKey" limit="open" defaultValue="" javascript="onchange='this.form.submit();'" />
                    </form>
                </div>

            </div>
        </div>
    </div>
</form>


<script type="text/javascript">

    changeSearchTab(document.getElementById('default').value);

    // tab ids should be searchTab_concept
    // tab content ids should be searchTab_concept_content
    function changeSearchTab(tabObj, focusToId) {
        if (typeof tabObj == 'string')
            tabObj = document.getElementById(tabObj);

        if (tabObj) {
            var tabs = tabObj.parentNode.parentNode.getElementsByTagName('a');
            for (var i = 0; i < tabs.length; ++i) {
                if (tabs[i].className.indexOf('current') != -1) {
                    manipulateClass('remove', tabs[i], 'current');
                }
                var tabContentId = tabs[i].id + '_content';
                if (tabs[i].id == tabObj.id)
                    showLayer(tabContentId);
                else
                    hideLayer(tabContentId);
            }
            addClass(tabObj, 'current');

            if (focusToId)
                document.getElementById(focusToId).focus();
            else
                tabObj.blur();
        }
    }



</script>
